package com.tuanzi.loan.business.service.sms.el.evaluator;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Component;

import com.tuanzi.loan.business.service.sms.el.EvaluateRoot;
import com.tuanzi.loan.business.service.sms.el.MatchRuleContext;
import com.tuanzi.loan.business.service.sms.vo.SmsSearchResponse;
import com.tuanzi.loan.core.util.SpringContextHolder;

@Component
public class MatchRuleRootEvaluator implements EvaluateRoot {

	public BaseInfoEvaluator baseInfo() {
		return SpringContextHolder.getBean(BaseInfoEvaluator.class);
	}

	public EliminateBlackListEvaluator eliminateBlackList() {
		return SpringContextHolder.getBean(EliminateBlackListEvaluator.class);
	}

	public EliminateActivityEvaluator eliminateActivity() {
		return SpringContextHolder.getBean(EliminateActivityEvaluator.class);
	}

	public List<String> distinctGet() {
		List<SmsSearchResponse> responses = MatchRuleContext.getMatchRuleContext().getResponses();
		MatchRuleContext.removeMatchRuleContext();
		return responses.stream().map(SmsSearchResponse::getPhone).distinct().collect(Collectors.toList());
	}
}
